﻿using B.S.DataBase.MyProject.Domain.基础设置;
using B.S.DataBase.MyProject.ErrorCode;
using B.S.DataBase.MyProject.Infrastructure;
using MediatR;
<<<<<<<< HEAD:MedicalPCTerminal.Read.API/Appcation/CommandHandlers/BasicSettingsCommandHandler/GetDiseaseManagementCommandHandler.cs
using MedicalPCTerminal.Read.API.Appcation.Commands.BasicSettingsCommand;

namespace MedicalPCTerminal.Read.API.Appcation.CommandHandlers.BasicSettingsCommandHandler
========
using MedicalPCTerminal.Read.API.Appcation.Commands.基础设置;

namespace MedicalPCTerminal.Read.API.Appcation.CommandHandlers.基础设置
>>>>>>>> parent of fe317f5 (修改命名空间):MedicalPCTerminal.Read.API/Appcation/CommandHandlers/基础设置/GetDiseaseManagementCommandHandler.cs
{    /// <summary>
     /// 种病管理查询命令处理
     /// </summary>
    public class GetDiseaseManagementCommandHandler : IRequestHandler<GetDiseaseManagementCommand, APIResult<List<DiseaseManagement>>>
    {

        /// <summary>
        /// SqlSugar
        /// </summary>
        private readonly SqlSugarContext sqlSugar;
        /// <summary>
        /// 构造方法
        /// </summary>
        public GetDiseaseManagementCommandHandler(SqlSugarContext sqlSugar)
        {
            this.sqlSugar = sqlSugar;
        }
        /// <summary>
        /// 处理
        /// </summary>
        /// <param name="request">请求</param>
        /// <param name="cancellationToken">取消</param>
        /// <returns></returns>
        public Task<APIResult<List<DiseaseManagement>>> Handle(GetDiseaseManagementCommand request, CancellationToken cancellationToken)
        {
            try
            {
                APIResult<List<DiseaseManagement>> result = new APIResult<List<DiseaseManagement>>();
                var list = sqlSugar.db.Queryable<DiseaseManagement>().Where(x=>x.DiseaseName==request.DiseaseName&&x.IsDel==false);
                list = list.OrderByDescending(x => x.DiseaseName);
                result.Code = APIEnum.查询成功;
                result.Msg = APIEnum.查询成功.ToString();
                result.data = list.ToList();
                return Task.FromResult(result);
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
